<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>被测人管理</title>
<!-- 导入jquery核心类库 -->
<script type="text/javascript"
	src="${pageContext.request.contextPath }/js/jquery-1.8.3.js"></script>
<!-- 导入easyui类库 -->
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/js/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/js/easyui/themes/icon.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/js/easyui/ext/portal.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/css/default.css">	
<script type="text/javascript"
	src="${pageContext.request.contextPath }/js/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath }/js/easyui/ext/jquery.portal.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath }/js/easyui/ext/jquery.cookie.js"></script>
<script
	src="${pageContext.request.contextPath }/js/easyui/locale/easyui-lang-zh_CN.js"
	type="text/javascript"></script>

<script type="text/javascript">

	
	function getQueryParams(queryParams) {  
		var searchcontent = $('#searchcontent').val();
		var sc_managerName = $('#sc_managerName').val();
		var sc_managerMobile = $('#sc_managerMobile').val();
	     queryParams.username = searchcontent;  
	     queryParams.managerName = sc_managerName;  
	     queryParams.managerMobile = sc_managerMobile;  
	     return queryParams;  
	   
	 }  
	
	 //增加查询参数，重新加载表格  
    function reloadgrid() {  
  
        //查询参数直接添加在queryParams中      
        var queryParams = $('#grid').datagrid('options').queryParams;  
        getQueryParams(queryParams);  
        $('#grid').datagrid('options').queryParams = queryParams;  
        $("#grid").datagrid('load');  
    }  
	 
	function doSearch(){		
		reloadgrid();
	}
	


	// 定义列
	var columns = [ [ {
		field : 'username',
		title : '姓名',
		width : 80,	
		/* align : 'center' */
	},  {
		field : 'sex',
		title : '性别',
		width : 40,
		formatter:formatterSex
		
	},  {
		field : 'company',
		title : '公司名',
		width : 120,
		
	}, {
		field : 'departname',
		title : '部门',
		width : 120,
		/* align : 'center' */
	}, {
		field : 'phone',
		title : '客户电话',
		width : 120,
		/* align : 'center' */
	}, {
		field : 'numberid',
		title : '编号',
		width : 60,
		
	}, {
		field : 'managerName',
		title : '量体师',
		width : 60,
		
	}, {
		field : 'managerMobile',
		title : '量体师注册手机号',
		width : 120,
		
	}, {
		field : 'rsn',
		title : 'E尺SN',
		width : 80,
		
	}, {
		field : 'rmac',
		title : 'E尺MAC',
		width : 140,
		
	}, {
		field : 'devsys',
		title : '手机类型',
		width : 140,
		formatter:formatterDevSys
		
	}, {
		field : 'devmodel',
		title : '手机型号',
		width : 140,
		
	}, {
		field : 'sysversion',
		title : '系统版本',
		width : 140,
		
	}, {
		field : 'addtime',
		title : '添加时间 ',
		width : 130,
		formatter:formatterDate
		
	}, {
		field : 'id',
		title : '操作',
		width : 160,
		
		formatter:formatterId
	} ] ];
	
	
	function formatterDevSys(value,row,index){
		if(value==1){
			return 'IOS';
		}else if(value==2){
			return 'Android';

		}
		
	}
	
	function formatterId(value,row,index) {
		return "<a onclick=showDetails("+index+") href=#>详情</a>";
	}
	function showDetails(index){
	    $('#grid').datagrid('selectRow',index);// 关键在这里  
	    var row = $('#grid').datagrid('getSelected'); 
	    if(row){ 
			location.href="${pageContext.request.contextPath}/page.customerdetails.ashx?id="+row.id;

		}
	}
	
	function formatterDate(value){
		if(value==''||null==value){
			return '';
		}
		var now = new Date(parseInt(value) * 1000);  
		var year=now.getYear()+1900; 
		var month=now.getMonth()+1; 
		var date=now.getDate(); 
		var hour=now.getHours(); 
		var minute=now.getMinutes();
		minute= (minute > 9) ? minute=minute : minute='0'+minute;
		//var second=now.getSeconds(); 
		return year+"-"+month+"-"+date+" "+hour+":"+minute; 
	}
	
	function doFuQuan(index){
	    $('#grid').datagrid('selectRow',index);// 关键在这里  
	    var row = $('#grid').datagrid('getSelected'); 

	    if(row){
			$.messager.alert("提示", "正在完善...", 'info');
		}
	}
	
	function formatterSex(value,row,index){
		if(row.sex==1){
			return "男";
		}else if(row.sex==0){
			return "女";
		}
	}

	$(function(){
		
		$('#search').click(doSearch);
	});
	$(function(){
		// 先将body隐藏，再显示，不会出现页面刷新效果
		$("body").css({visibility:"visible"});
		
		// 收派标准数据表格
		$('#grid').datagrid( {
			iconCls : 'icon-forward',
			fit : true,
			border : false,
			rownumbers : true,
			singleSelect:true,
			striped : true,
			toolbar : '#tb',
			url : "${pageContext.request.contextPath}/page.customerList.ashx",
			idField : 'id',
			columns : columns,
			pageList: [20,50,100,200],
			pagination:true,
			view:myview,
			emptyMsg:"<font size=5>暂无记录</font>"
			
		});
	});	
		
		

	
	
	
	var myview = $.extend({},$.fn.datagrid.defaults.view,{
		onAfterRender:function(target){
			$.fn.datagrid.defaults.view.onAfterRender.call(this,target);
			var opts = $(target).datagrid('options');
			var vc = $(target).datagrid('getPanel').children('div.datagrid-view');
			vc.children('div.datagrid-empty').remove();
			if (!$(target).datagrid('getRows').length){
				var d = $('<div class="datagrid-empty"></div>').html(opts.emptyMsg || 'no records').appendTo(vc);
				d.css({
					position:'absolute',
					left:0,
					top:50,
					width:'100%',
					textAlign:'center'
				});
			}
		}
	});

 
	
		
</script>	
</head>
<body class="easyui-layout" >
	<div region="center"><table id="grid"></table></div>

		<div id="tb" style="padding:5px;height:auto">
		<div style="margin-bottom:5px">
		
			
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;量体师姓名: <input id="sc_managerName" class="easyui-textbox" style="width:80px">
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;量体师注册手机: <input id="sc_managerMobile" class="easyui-textbox" style="width:80px">
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;客户姓名: <input id="searchcontent" class="easyui-textbox" style="width:80px">
			<a href="#"  id="search" class="easyui-linkbutton" iconCls="icon-search">搜索</a>
		
		</div>
	</div>
</body>
</html>